<!-- 库房管理----库位推荐 -->
<script lang="ts">
import { reactive } from "vue";
import { inRecommendation, outRecommendation } from "/@/api/wms/console";
import { errorMessage } from "/@/utils/message";

export default {
  name: "recommendLocation",
  props: {
    bnoNo: {
      type: String,
      default: ""
    },
    detailId: {
      type: Number,
      default: 0
    },
    materialCode: {
      type: String,
      default: ""
    },
    bnoType: {
      type: String,
      default: ""
    },
    operation: {
      type: String,
      default: ""
    }
  },
  setup(props) {
    // 库位推荐---操作开始
    // 库位推荐操作绑定数据
    const recommendData = reactive({
      bnoNo: "",
      detailId: 0,
      materialCode: "",
      operation: "",
      bnoType: "",
      dialogShow: false,
      detailData: [] as any[]
    });
    // 获取数据
    const queryList = () => {
      recommendData.bnoNo = props.bnoNo;
      recommendData.detailId = props.detailId;
      recommendData.materialCode = props.materialCode;
      recommendData.operation = props.operation;
      recommendData.bnoType = props.bnoType;
      if (recommendData.operation == "入库") {
        inRecommendation(recommendData).then((res: any) => {
          if (res.code === 0) {
            recommendData.detailData = res.data;
          } else {
            errorMessage(res.message);
          }
        });
      } else {
        outRecommendation(recommendData).then((res: any) => {
          if (res.code === 0) {
            recommendData.detailData = res.data;
          } else {
            errorMessage(res.message);
          }
        });
      }
    };
    return {
      recommendData,
      queryList
    };
  },
  mounted() {
    this.queryList();
  }
};
</script>
<template>
  <div style="margin-left: 50px">
    <p
      class="s_list"
      v-for="(item, index) in recommendData.detailData"
      :key="item.id"
    >
      <span class="s_index">{{ index + 1 }}</span>
      <span style="font-size: 12px">
        {{ item.stgeName }}/{{ item.stgeLocCode }}/{{ item.stockQty }}</span
      >
    </p>
  </div>
</template>
<style lang="scss" scoped>
div p.s_list {
  display: inline-block;
  margin-right: 20px;
  margin-bottom: 5px;
  span.s_index {
    display: inline-block;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    border-radius: 50%;
    background: #60b8ff;
    color: #fff;
    margin-right: 5px;
  }
}
</style>
